package io.aggression.test.persistence;

import com.mongodb.BasicDBObject;
import com.mongodb.DBObject;
import com.mongodb.DBCursor;
import com.mongodb.DB;
import com.mongodb.Bytes;
import com.mongodb.DBCollection;
import com.mongodb.MongoClient;


public class TransactionNotifier {

	private final static TransactionNotifier INSTANCE = new TransactionNotifier();

	private TransactionNotifier(){

	}

	public static TransactionNotifier getInstance(){
		return INSTANCE;
	}

	public static void main(String[] argv) throws Exception{

		MongoClient mongoClient = new MongoClient();

		DB db = mongoClient.getDB("local");

		DBCollection collection = db.getCollection("oplog.rs");

		DBCursor myCursor = collection.find().sort(new BasicDBObject("$natural", 1)).addOption(Bytes.QUERYOPTION_TAILABLE).addOption(Bytes.QUERYOPTION_AWAITDATA);

		while (true){

			if (myCursor.hasNext()){

				BasicDBObject doc = (BasicDBObject) myCursor.next();
				System.out.println("123: " + doc);

			}



		}


		//mongoClient.close();


	}




}
